package com.spring.dao.lmpl;

import com.spring.dao.AccountDao;
import com.spring.utils.ThreddUtis;
import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.management.Query;
import java.sql.SQLException;
import java.util.Observer;
@Repository
public class Accountlmpl implements AccountDao {

    //qureyRunner update

@Autowired
private QueryRunner queryRunner;

@Autowired
 private ThreddUtis threddUtis;

    @Override
    public void out(String name, Double money) {
        String sql = "update account set money = money - ? where name = ?";
         try{
             switch (queryRunner.update(threddUtis.getConnection, sql, money, name)) {
             }
         }catch (SQLException e) {
             e.printStackTrace();
         }

    }

    @Override
    public void in(String name, Double money) {
        String sql = "update account set money = money + ? where name = ?";
        try{
            queryRunner.update(threddUtis.getConnection(),sql,money,name);
        }catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
